package com.ruoyi.device.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.device.domain.DeviceUserRegister;
import com.ruoyi.device.service.IDeviceUserRegisterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

@RestController
@RequestMapping("/device/deviceUserRegister")
public class DeviceUserRegisterController extends BaseController {
    @Autowired
    private IDeviceUserRegisterService registerService;
    /**
     * 获取app注册用户列表
     * @param register
     * @return
     */
    @GetMapping("/list")
    public TableDataInfo list(DeviceUserRegister register){
        startPage();
        List<DeviceUserRegister> list = registerService.getRegisterList(register);
        return  getDataTable(list);
    }

    /**
     * 导出app注册用户列表
     * @param response
     * @param register
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response , DeviceUserRegister register){
        List<DeviceUserRegister> list = registerService.getRegisterList(register);
        ExcelUtil<DeviceUserRegister> util = new ExcelUtil<>(DeviceUserRegister.class);
        util.exportExcel(response, list, "app用户注册记录数据");
    }
    /**
     * 获取app注册用户详情
     * @param id
     * @return
     */
    @GetMapping(value = "/getInfo/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id){
        return success(registerService.getRegisterById(id));
    }
    /**
     * 注册用户审核
     * @param register
     * @return
     */
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody DeviceUserRegister register){
        return toAjax(registerService.editRegister(register));
    }
}
